home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1996 #15 / Monster Media Number 15 (Monster Media)(July 1996).ISO / bbs_util / bsrc_260.zip / INCLUDE.ZIP / AGLCRC.H next >
C/C++ Source or Header  |  1996-02-20  |  10KB  |  199 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*              (C) Copyright 1987-96, Bit Bucket Software Co.              */
  11. /*                                                                          */
  12. /*             This header file was written by Michael Buenter              */
  13. /*               Based on original header file by Arjen Lentz               */
  14. /*                  Hydra CRC definitions for BinkleyTerm                   */
  15. /*                                                                          */
  16. /*                                                                          */
  17. /*    For complete  details  of the licensing restrictions, please refer    */
  18. /*    to the License  agreement,  which  is published in its entirety in    */
  19. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.260.    */
  20. /*                                                                          */
  21. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  22. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  23. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  24. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  25. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  26. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  27. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  28. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  29. /*                                                                          */
  30. /*                                                                          */
  31. /* You can contact Bit Bucket Software Co. at any one of the following      */
  32. /* addresses:                                                               */
  33. /*                                                                          */
  34. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  35. /* P.O. Box 460398                AlterNet 7:42/1491                        */
  36. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  37. /*                                Internet f491.n343.z1.fidonet.org         */
  38. /*                                                                          */
  39. /* Please feel free to contact us at any time to share your comments about  */
  40. /* our software and/or licensing policies.                                  */
  41. /*                                                                          */
  42. /*                                                                          */
  43. /*--------------------------------------------------------------------------*/
  44.  
  45. /*============================================================ Rev. 17 Jan 1993
  46.   Routines for table driven CRC-16 & CRC-32, including building tables
  47.   Refer to CRC.DOC for information and documentation.
  48.   This header file can be used with either CRC.C or its 80x86 ASM equivalent.
  49.   Define CRC_TINY to use with CRC_TINY.C.
  50.   -----------------------------------------------------------------------------
  51.  
  52.            Information collected and edited by Arjen G. Lentz
  53.          Sourcecode in C and 80x86 ASM written by Arjen G. Lentz
  54.           COPYRIGHT (C) 1992-1993; ALL RIGHTS RESERVED
  55.  
  56.  
  57.   CONTACT ADDRESS
  58.  
  59.   LENTZ SOFTWARE-DEVELOPMENT    Arjen Lentz @
  60.   Langegracht 7B        AINEX-BBS +31-33-633916
  61.   3811 BT  Amersfoort        FidoNet 2:283/512
  62.   The Netherlands        arjen_lentz@f512.n283.z2.fidonet.org
  63.  
  64.  
  65.   DISCLAIMER
  66.  
  67.   This information is provided "as is" and comes with no warranties of any
  68.   kind, either expressed or implied. It's intended to be used by programmers
  69.   and developers. In no event shall the author be liable to you or anyone
  70.   else for any damages, including any lost profits, lost savings or other
  71.   incidental or consequential damages arising out of the use or inability
  72.   to use this information.
  73.  
  74.  
  75.   LICENCE
  76.  
  77.   This package may be freely distributed provided the files remain together,
  78.   in their original unmodified form.
  79.   All files, executables and sourcecode remain the copyrighted property of
  80.   Arjen G. Lentz and LENTZ SOFTWARE-DEVELOPMENT.
  81.   Licence for any use granted, provided this notice & CRC.DOC are included.
  82.   For executable applications, credit should be given in the appropriate
  83.   place in the program and documentation.
  84.   These notices must be retained in any copies of any part of this
  85.   documentation and/or software.
  86.  
  87.   Any use of, or operation on (including copying/distributing) any of
  88.   the above mentioned files implies full and unconditional acceptance of
  89.   this license and disclaimer.
  90.  
  91. =============================================================================*/
  92.  
  93. #ifndef __CRC_DEF_
  94. #define __CRC_DEF_
  95. /*#include "2types.h"*/
  96.  
  97. #ifndef FAR
  98. #ifdef __MSDOS__
  99. #   if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
  100. #      define FAR far
  101. #   else
  102. #      define FAR
  103. #   endif
  104. #else
  105. #   define FAR
  106. #endif
  107. #endif
  108.  
  109. #ifdef __cplusplus
  110. extern "C"
  111. {
  112. #endif
  113.  
  114.     /* --------------------------------------------------------------------- */
  115.     /* CRC-16 used by ARC and LH, use crc16___ routines                         */
  116.     /* --------------------------------------------------------------------- */
  117. #define CRC16APOLY    (0xA001)            /* Generator polynomial number         */
  118. #define CRC16AINIT    (0)                    /* Initial CRC value for calculation */
  119. #define CRC16APOST(crc) (crc)            /* CRC Postconditioning before xmit  */
  120. #define CRC16ATEST    (0)                    /* Result to test for at receiver    */
  121.  
  122.     /* --------------------------------------------------------------------- */
  123.     /* CRC-16 CCITT proper                                                     */
  124.     /* --------------------------------------------------------------------- */
  125. #define CRC16POLY    (0x8408)            /* Generator polynomial number         */
  126. #define CRC16INIT    (0xFFFF)            /* Initial CRC value for calculation */
  127. #define CRC16POST(crc)    (~(crc))        /* CRC Postconditioning before xmit  */
  128. #define CRC16TEST    (0xF0B8)            /* Result to test for at receiver    */
  129.  
  130.     /* --------------------------------------------------------------------- */
  131.     /* CRC-16 CCITT upside-down                                                 */
  132.     /* --------------------------------------------------------------------- */
  133. #define CRC16RPOLY    (0x1021)            /* Generator polynomial number         */
  134. #define CRC16RINIT    (0)                    /* Initial CRC value for calculation */
  135. #define CRC16RPOST(crc) (crc)            /* CRC Postconditioning before xmit  */
  136. #define CRC16RTEST    (0)                    /* Result to test for at receiver    */
  137.  
  138.     /* --------------------------------------------------------------------- */
  139.     /* CRC-32 CCITT                                                          */
  140.     /* --------------------------------------------------------------------- */
  141. #define CRC32POLY      (0xEDB88320L)    /* Generator polynomial number         */
  142. #define CRC32INIT      (0xFFFFFFFFL)    /* Initial CRC value for calculation */
  143. #define CRC32POST(crc) (~(crc))            /* CRC Postconditioning before xmit  */
  144. #define CRC32TEST      (0xDEBB20E3L)    /* Result to test for at receiver    */
  145.  
  146.     /* --------------------------------------------------------------------- */
  147.     /* Number of items in CRC table                                          */
  148.     /* --------------------------------------------------------------------- */
  149. #ifndef CRC_TINY
  150. #define CRC_TABSIZE (256)                /* Normal 256-entry table             */
  151. #else
  152. #define CRC_TABSIZE (2 * 16)            /* Tiny 2x16-entry table             */
  153. #endif
  154.  
  155.     /* --------------------------------------------------------------------- */
  156.     /* CRC-16 proper, used for both CCITT and the one used by ARC             */
  157.     /* --------------------------------------------------------------------- */
  158.     void crc16init (word FAR * crctab, word poly);
  159.     word crc16block (word FAR * crctab, word crc, byte FAR * buf, word len);
  160. #ifndef CRC_TINY
  161. #define crc16upd(crctab,crc,c) \
  162.           ((crctab)[((crc) ^ (c)) & 0xff] ^ ((crc) >> 8))
  163. #else
  164.     word crc16upd (word FAR * crctab, word crc, byte c);
  165. #endif
  166.  
  167.     /* --------------------------------------------------------------------- */
  168.     /* CRC-16 upside-down, transmitted high-byte first                         */
  169.     /* --------------------------------------------------------------------- */
  170.     void crc16rinit (word FAR * crctab, word poly);
  171.     word crc16rblock (word FAR * crctab, word crc, byte FAR * buf, word len);
  172. #ifndef CRC_TINY
  173. #define crc16rupd(crctab,crc,c) \
  174.           ((crctab)[(((crc) >> 8) ^ (c)) & 0xff] ^ ((crc) << 8))
  175. #else
  176.     word crc16rupd (word FAR * crctab, word crc, byte c);
  177. #endif
  178.  
  179.     /* --------------------------------------------------------------------- */
  180.     /* CRC-32                                                                 */
  181.     /* --------------------------------------------------------------------- */
  182.     void crc32init (ULONG FAR * crctab, ULONG poly);
  183.     ULONG crc32block (ULONG FAR * crctab, ULONG crc, byte FAR * buf, word len);
  184. #ifndef CRC_TINY
  185. #define crc32upd(crctab,crc,c) \
  186.           ((crctab)[((int) (crc) ^ (c)) & 0xff] ^ ((crc) >> 8))
  187. #else
  188.     ULONG crc32upd (ULONG FAR * crctab, ULONG crc, byte c);
  189. #endif
  190.  
  191. #ifdef __cplusplus
  192. }
  193.  
  194. #endif
  195.  
  196. #endif                            /*__CRC_DEF_*/
  197.  
  198. /* end of crc.h ------------------------------------------------------------ */
  199.